fix(goose): only send agent-session-id when a session exists#6657
Merged
codefromthecrypt merged 1 commit intomainfrom Jan 27, 2026
Merged
fix(goose): only send agent-session-id when a session exists#6657codefromthecrypt merged 1 commit intomainfrom
codefromthecrypt merged 1 commit intomainfrom
Conversation
| // | ||
| /// # Parameters | ||
| /// - `session_id`: Use `None` only for configuration or pre-session tasks. | ||
| async fn complete_with_model( |
Collaborator
Author
There was a problem hiding this comment.
this is the key place though some others had to switch to Option to support pre-session tasks
355230c to
5b1f5c5
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Stops propagating agent-session-id unless a real goose session exists, while ensuring non-OpenAI-compatible providers can still receive the header for correlation when a session does exist.
Changes:
- Updates the provider completion path to accept
session_id: Option<&str>and only injectagent-session-idwhenSome(non_empty). - Removes session-id requirements from model discovery/config/probing paths (
fetch_supported_models/fetch_recommended_models) and updates call sites accordingly. - Adds/updates tests to cover header injection/removal behavior and MCP session propagation edge cases.
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/goose/tests/mcp_integration_test.rs | Updates mock provider signature to accept optional session id. |
| crates/goose/tests/agent.rs | Adapts test provider to optional session id for completion. |
| crates/goose/src/providers/xai.rs | Threads optional session id through completion requests. |
| crates/goose/src/providers/venice.rs | Removes session requirement for model fetch; optional session for completion. |
| crates/goose/src/providers/tetrate.rs | Removes session requirement for model fetch; optional session for completion. |
| crates/goose/src/providers/testprovider.rs | Propagates optional session id through wrapped provider calls. |
| crates/goose/src/providers/snowflake.rs | Threads optional session id through requests. |
| crates/goose/src/providers/sagemaker_tgi.rs | Conditionally propagates session id via SageMaker custom attributes. |
| crates/goose/src/providers/openrouter.rs | Removes session requirement for model fetch; conditional session propagation via payload/user + header. |
| crates/goose/src/providers/openai.rs | Removes session requirement for model fetch; optional session for completion calls. |
| crates/goose/src/providers/ollama.rs | Removes session requirement for model fetch; optional session for completion. |
| crates/goose/src/providers/litellm.rs | Removes session requirement for model fetch; optional session for completion + cache-control detection. |
| crates/goose/src/providers/lead_worker.rs | Updates delegation to use complete_with_model with optional session id; removes session from model fetch. |
| crates/goose/src/providers/google.rs | Removes session requirement for model fetch; optional session propagation for requests/streaming. |
| crates/goose/src/providers/githubcopilot.rs | Removes session requirement for model fetch; optional session propagation for requests. |
| crates/goose/src/providers/gemini_cli.rs | Updates provider signature to optional session id (still ignored for CLI). |
| crates/goose/src/providers/gcpvertexai.rs | Conditionally injects session header for Vertex AI requests; removes session from model fetch. |
| crates/goose/src/providers/databricks.rs | Removes pre-session UUID generation for probing; removes session requirement for model fetch; optional session for completion. |
| crates/goose/src/providers/cursor_agent.rs | Updates provider signature to optional session id (still ignored for CLI). |
| crates/goose/src/providers/codex.rs | Updates provider signature to optional session id (still ignored for CLI). |
| crates/goose/src/providers/claude_code.rs | Updates provider signature to optional session id (still ignored for CLI constraints). |
| crates/goose/src/providers/chatgpt_codex.rs | Conditionally injects agent-session-id header for streaming requests; removes session from model fetch. |
| crates/goose/src/providers/canonical/build_canonical_models.rs | Removes pre-session UUID generation for provider probing/model fetch. |
| crates/goose/src/providers/bedrock.rs | Conditionally injects agent-session-id header into AWS Bedrock requests. |
| crates/goose/src/providers/base.rs | Changes provider trait APIs to use optional session id for completion and removes session from model fetch APIs. |
| crates/goose/src/providers/azure.rs | Threads optional session id through requests. |
| crates/goose/src/providers/auto_detect.rs | Removes pre-session UUID usage; uses sessionless model fetch for provider detection. |
| crates/goose/src/providers/api_client.rs | Makes request builder session-aware (optional) and adds tests for header set/replace/remove behavior. |
| crates/goose/src/providers/anthropic.rs | Removes session requirement for model fetch; optional session for completion; ensures streaming still passes session. |
| crates/goose/src/context_mgmt/mod.rs | Updates test provider signature to optional session id. |
| crates/goose/src/agents/reply_parts.rs | Updates test provider signature to optional session id. |
| crates/goose/src/agents/mcp_client.rs | Removes connection-scoped fallback session id; makes MCP session id propagation optional and removable. |
| crates/goose/examples/image_tool.rs | Updates example to use complete_with_model(None, ...) for pre-session usage. |
| crates/goose/examples/databricks_oauth.rs | Updates example to use complete_with_model(None, ...) for pre-session usage. |
| crates/goose-server/src/routes/config_management.rs | Removes pre-session UUID generation; uses sessionless model fetch/provider detect. |
| crates/goose-cli/src/commands/configure.rs | Removes pre-session UUID generation; switches config checks to sessionless model fetch or complete_with_model(None, ...). |
Comments suppressed due to low confidence (1)
crates/goose/examples/image_tool.rs:71
&provider.get_model_config()borrows a temporaryModelConfigacross.await, which will not compile; assignlet model_config = provider.get_model_config();before the call and pass&model_config.
let (response, usage) = provider
.complete_with_model(
None,
&provider.get_model_config(),
"You are a helpful assistant. Please describe any text you see in the image.",
&messages,
&[Tool::new("view_image", "View an image", input_schema)],
)
michaelneale
approved these changes
Jan 26, 2026
Collaborator
michaelneale
left a comment
There was a problem hiding this comment.
make sense - nice tidy up
Keep session headers 1:1 with session manager records so we avoid confusing or conflicting IDs. Backfill propagation across API clients and provider requests (including Bedrock's AWS runtime path) so OpenAI-compatible Envoy AI Gateway clones also see agent-session-id. Keep session_id required for normal agent flows; allow None only for configuration and pre-session paths like model discovery, provider detection, and auth probes. Signed-off-by: Adrian Cole <adrian@tetrate.io>
5b1f5c5 to
3df7224
Compare
zanesq
added a commit
that referenced
this pull request
Jan 27, 2026
…upport * origin/main: (79 commits) fix[format/openai]: return error on empty msg. (#6511) Fix: ElevenLabs API Key Not Persisting (#6557) Logging uplift for model training purposes (command injection model) [Small change] (#6330) fix(goose): only send agent-session-id when a session exists (#6657) BERT-based command injection detection in tool calls (#6599) chore: [CONTRIBUTING.md] add Hermit to instructions (#6518) fix: update Gemini context limits (#6536) Document r slash command (#6724) Upgrade GitHub Actions to latest versions (#6700) fix: Manual compaction does not update context window. (#6682) Removed the Acceptable Usage Policy (#6204) Document spellcheck toggle (#6721) fix: docs workflow cleanup and prevent cancellations (#6713) Docs: file bug directly (#6718) fix: dispatch ADD_ACTIVE_SESSION event before navigating from "View All" (#6679) Speed up Databricks provider init by removing fetch of supported models (#6616) fix: correct typos in documentation and Justfile (#6686) docs: frameDomains and baseUriDomains for mcp apps (#6684) docs: add Remotion video creation tutorial (#6675) docs: export recipe and copy yaml (#6680) ... # Conflicts: # ui/desktop/src/hooks/useChatStream.ts
katzdave
added a commit
that referenced
this pull request
Jan 27, 2026
…ovider * 'main' of github.com:block/goose: fix slash and @ keyboard navigation popover background color (#6550) fix[format/openai]: return error on empty msg. (#6511) Fix: ElevenLabs API Key Not Persisting (#6557) Logging uplift for model training purposes (command injection model) [Small change] (#6330) fix(goose): only send agent-session-id when a session exists (#6657) BERT-based command injection detection in tool calls (#6599) chore: [CONTRIBUTING.md] add Hermit to instructions (#6518) fix: update Gemini context limits (#6536) Document r slash command (#6724) Upgrade GitHub Actions to latest versions (#6700)
zanesq
added a commit
that referenced
this pull request
Jan 27, 2026
* 'main' of github.com:block/goose: Create default gooseignore file when missing (#6498) fix slash and @ keyboard navigation popover background color (#6550) fix[format/openai]: return error on empty msg. (#6511) Fix: ElevenLabs API Key Not Persisting (#6557) Logging uplift for model training purposes (command injection model) [Small change] (#6330) fix(goose): only send agent-session-id when a session exists (#6657) BERT-based command injection detection in tool calls (#6599) chore: [CONTRIBUTING.md] add Hermit to instructions (#6518) fix: update Gemini context limits (#6536) Document r slash command (#6724) Upgrade GitHub Actions to latest versions (#6700) fix: Manual compaction does not update context window. (#6682) Removed the Acceptable Usage Policy (#6204) Document spellcheck toggle (#6721) fix: docs workflow cleanup and prevent cancellations (#6713) Docs: file bug directly (#6718)
This was referenced Jan 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stop adding the
agent-session-idheader unless there is a current session. This keeps headers 1:1 with session manager records and avoids confusing or conflicting session IDs.Noneis for configuration or pre-session paths (model discovery, provider detection, auth probes, canonical model checks).This also backfills propagation of non-basic OpenAI apis so they can also see
agent-session-id(e.g., Anthropic, Bedrock, Vertex etc). This is important because proxies like Envoy AI Gateway and Ollama started supporting non-OpenAI endpoints recently. With this, they can do log correlation on goose session ID.Type of Change
AI Assistance
Testing
Added some edge case tests.
Related Issues
Tuneup of #6626